
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript">
    function userDeleteOrActive(id) {
        if(confirm("您确定要删除这个用户？")) {
            location.href="${pageContext.request.contextPath}/user/deleteUser?id="+id;
        }
    }

</script>

<div class="data_list">
    <div class="data_list_title" style="text-align: center; font-size: 35px">
        用户管理
    </div>
    <form name="myForm" class="form-search" method="post" action="${pageContext.request.contextPath}/user/findAll">
        <button class="btn btn-primary" type="button" style="margin-right: 50px;"
                onclick="javascript:location.href='${pageContext.request.contextPath}/user/addUser?para=add'">添加</button>
        <span class="data_search">
					<select id="conditions" name="conditions" style="width: 80px;">
                        <option value="name">姓名</option>
						<option value="sex">性别</option>
						<option value="phone">电话号码</option>
					</select>
					&nbsp;<input id="information" name="information" type="text" value="${keyword}" style="width:120px;height: 30px;" class="input-medium search-query" >
					&nbsp;<button type="submit" class="btn btn-info">搜索</button>
				</span>
    </form>
    <div>
        <table class="table table-hover table-striped table-bordered">
            <tr>
                <th>用户名</th>
                <th>姓名</th>
                <th>性别</th>
                <th>联系电话</th>
                <th>角色</th>
            </tr>
            <c:forEach items="${users}" var="user">
                <tr>
                    <td>${user.username}</td>
                    <td>${user.name}</td>
                    <td>${user.sex}</td>
                    <td>${user.phone}</td>
                    <td>${user.role.chName}</td>
                    <td>
                        <button class="btn btn-primary" type="button" onclick="location.href='${pageContext.request.contextPath}/user/findOneUser?id=${user.id}'">修改</button>&nbsp;
                        <button class="btn btn-primary" type="button" onclick="userDeleteOrActive(${user.id})">删除</button>
                    </td>
                </tr>
            </c:forEach>

        </table>
    </div>
    <div align="center"><font color="red"></font></div>
</div>
